<!--
 * @Descripttion:
 * @version: 1.0.0
 * @Author: htang
 * @Date: 2023-11-06 17:28:36
 * @LastEditors: htang
 * @LastEditTime: 2024-01-22 20:48:07
-->
<template>
  <div class="jeecg-basic-table maintain-lists-view">
    <div class="tip">
      <span>维修记录</span>
    </div>
    <div class="jeecg-search-layer">
      <a-form ref="form" :model="queryParam">
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-item label="站点信息">
              <a-select v-model:value="queryParam.stationCode" allowClear placeholder="请选择站点" showSearch>
                <template v-for="(item, index) in stationList" :key="index">
                  <a-select-option :value="item.id">
                    {{ item.name }}
                  </a-select-option>
                </template>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="检修时间：">
              <a-range-picker v-model:value="dateTime" format="YYYY-MM-DD HH:mm:ss" valueFormat="YYYY-MM-DD HH:mm:ss" show-time style="width: 100%" />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="24" style="text-align: right">
            <a-form-item>
              <a-button type="primary" @click="onSearch">查询</a-button>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div class="jeecg-table-view">
      <a-table :loading="loading" rowKey="id" :dataSource="dataSource" :columns="columns" :pagination="false">
        <template v-slot:bodyCell="{ column, record, index }">
          <template v-if="column.dataIndex == 'action'">
            <a @click="onDetail(record)">查看</a>
            <a-divider type="vertical" />
            <a style="color: red" @click="onDelete(record)">删除</a>
          </template>
        </template>
      </a-table>
      <Pagination
        v-model:current="ipagination.current"
        :pageSize="ipagination.pageSize"
        :total="ipagination.total"
        show-less-items
        @change="handlePageChange"
        :hideOnSinglePage="true"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useUserStore } from '/@/store/modules/user';
import { ref } from 'vue';
import { message } from 'ant-design-vue';
const userStore = useUserStore();

let loading = ref(false);

let queryParam = ref({
  // 点位名称
  name: '',
  // 站点编码
  stationCode: '',
  // 点位类型
  type: '',
  // 点位状态
  state: '',
});

let dateTime = ref([]);

let timeData = ref('');

// 站点列表
let stationList = ref(userStore.getStationList);

let ipagination = ref({
  current: 1,
  pageSize: 10,
  pageSizeOptions: ['10', '20', '30'],
  showTotal: (total, range) => {
    return range[0] + '-' + range[1] + ' 共' + total + '条';
  },
  showQuickJumper: true,
  showSizeChanger: true,
  total: 0,
});
// 数据源
let dataSource = ref([
  {
    id: '1',
    stationName: '北滘镇青年公园污水泵站',
    device: '门禁测试设备',
    remark: '设备更换',
    picture: '',
    action: '操作',
  },
  {
    id: '2',
    stationName: '北滘镇青年公园污水泵站',
    device: '门禁测试设备',
    remark: '设备更换',
    picture: '',
    action: '操作',
  },
]);
// 字段
let columns = ref([
  {
    title: '序号',
    dataIndex: 'index',
    key: 'id',
    width: 60,
    align: 'center',
    customRender: (t, r, index) => {
      return (ipagination.value.current - 1) * ipagination.value.pageSize + t.renderIndex + 1;
    },
  },
  {
    title: '站点',
    align: 'center',
    dataIndex: 'stationName',
  },
  {
    title: '设备',
    align: 'center',
    dataIndex: 'device',
  },
  {
    title: '故障描述',
    align: 'center',
    dataIndex: 'remark',
  },
  {
    title: '图片',
    align: 'center',
    dataIndex: 'picture',
  },
  {
    title: '操作',
    dataIndex: 'action',
    align: 'center',
  },
]);

/**
 * 初始化数据列表
 */
function init() {}

init();

/**
 * 搜索数据列表
 */
function onSearch() {
  setTimeout(() => {
    message.success('搜索成功');
  }, 1200);
}

/**
 * 切换当前页数
 */
function handlePageChange(page) {
  ipagination.value.current = page;
  init();
}

/**
 * 查看详情
 */
function onDetail() {}

/**
 * 删除数据
 */
function onDelete() {}
</script>

<style lang="less" scoped>
.maintain-lists-view {
  margin: 12px;
  background: #fff;
  .tip {
    width: 100%;
    height: 44px;
    padding: 0 0 0 43.3px;
    background: url('@/assets/images/img-17.png') no-repeat;
    background-size: 100% 100%;
    line-height: 44px;
    span {
      font-size: 16px;
      color: #fff;
    }
  }
  .jeecg-search-layer {
    margin: 0 0 17px;
    padding: 12px 15px;
    background: #fff;
    border-radius: 8px;
    .ant-form {
      max-width: auto;
      .ant-form-item {
        margin-bottom: 24px;
      }
      :deep(.ant-col) {
        width: auto;
      }
    }
  }
}
</style>